package com.aiguigu.safe;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MapNotSafeDemo {
    public static void main(String[] args) {
        // HashMap线程不安全
//        Map<String, String> map = new HashMap<>();
        //ConcurrentHashMap线程安全
        Map<String, String> map = new ConcurrentHashMap<>();


        map.put("1", "1");
        map.put("1", "2");
        System.out.println(map.size()+ "  "+map.get("1"));
    }
}
